<template>
    <div id="app" v-loading="loading">
        <div class="title">
            <a class="backPage iconfont icon-icon-test" @click="$router.back(-1)"></a>项目列表
        </div>
        <el-row class="tableBtnTop">
            <div class="search" style="margin-left:0;">
                <el-input placeholder="请输入项目名称"
                    v-model="searchText"
                    @keyup.enter.native="searchWill"
                >
                    <i slot="prefix" class="el-input__icon el-icon-search"
                    ></i>
                </el-input>
            </div>
            <el-button class="f1" @click="navAddProject">添加项目</el-button>
        </el-row>
        <el-table :data="tableData" border>
            <el-table-column prop="user" label="项目图标" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <div class="userHead">
                        <img :src="scope.row.icon" class="square" />
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="name" label="名称" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <div class="userHead">
                        {{
                            scope.row.name
                        }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="time" label="上架时间" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <div class="userHead">
                        {{
                            countTrialDate(scope.row.time_created * 1000)
                        }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="price" label="最低价格" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <font color="#F30">
                        {{
                            priceFormat(scope.row.min_amount)
                        }}
                    </font>
                </template>
            </el-table-column>
            <el-table-column prop="sell" label="近7天销量" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <div class="userHead">
                        {{
                            scope.row.sale_count
                        }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="sort" label="排序" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <div class="userHead">
                        {{
                            scope.row.sort
                        }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="isTem" label="是否有系统模板" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <div class="userHead">
                        {{
                            scope.row.template_id ? '有': '-'
                        }}
                    </div>
                </template>
            </el-table-column>
            <el-table-column prop="status" label="状态" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    <el-switch 
                        v-model="scope.row.status"
                        @change="handleStatusChange(scope.$index)"
                    >
                    </el-switch>
                </template>
            </el-table-column>
            <el-table-column prop="btn" label="操作" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                <div class="tableBtn">
                    <a class="blue" @click="$router.push('/task/projectDetail?id='+ scope.row.id)">查看</a>
                    <el-popconfirm title="真的要删除这条信息吗?"
                        @onConfirm="deleteSubject(scope.$index)"
                    >
                        <a class="gray" slot="reference">删除</a>
                    </el-popconfirm>
                </div>
                </template>
            </el-table-column>
        </el-table>
        <div class="paginationBlock">
            <el-pagination layout="prev, pager, next,total" 
                :total="listNumsTotal" :page-size="10"
                :current-page.sync="curPage"
                @current-change="changePage"
            >
            </el-pagination>
        </div>
    </div>
</template>

<script>
    import SubjectProject from './index.js';
    export default SubjectProject;
</script>
<style lang="scss" scoped>
    .userHead{
        cursor: auto;
    }
</style>